//创建临时文件 读取一些放在资源文件里面的文件
public void play(View view) throws IOException {
    int resid=R.raw.test;
    InputStream inputStream = context.getResources().openRawResource(resid);
    File videoPath = new File(context.getCacheDir(), "test.mp4");
    writeInputStreamToFile(inputStream, videoPath);

    System.out.println(videoPath);
    if(videoPath.exists()) {
        System.out.println("视频文件存在：" + videoPath);
        play(videoPath.getAbsolutePath(), surfaceHolder.getSurface());
    } else {
        System.out.println("视频文件不存在：" + videoPath);
    }
}
//写入
private static void writeInputStreamToFile(InputStream inputStream, File file) throws IOException {
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(file);
        byte[] buffer = new byte[1024];
        int length;
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
